package com.esunny.resourcevisualization.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @version 1.0.0.0
 * @ClassName StringToDateUtil
 * @Description 字符串转日期，日期转字符串
 * @Author baochencong
 * @Date 2021/3/11 14:31
 */
public class StringAndDateUtil {

    public static Date stringToDate(String dateString) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return simpleDateFormat.parse(dateString);
    }

    public static String dateToString(Date date){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return simpleDateFormat.format(date);
    }

}
